/******************************************************************************
 * (c) 2011 Komersi Software                                                  *
 * www.komersisoftware.com                                                    *
 *                                                                            *
 * This file is part of Tadah                                                 *
 * Licensed under GNU General Public License v2.0                             *
 * Check LICENSE.TXT for more information                                     *
 ******************************************************************************/
 
#ifndef _GENERICOBJECT_H_
#define _GENERICOBJECT_H_

#include <stdlib.h>

#include "column.h"

typedef struct generic_object
{
   ddl_column_t *column;
   void *value;
   struct generic_object *next;
} generic_object_t;

generic_object_t *object_from_column(generic_object_t *list, ddl_column_t *column);
generic_object_t *add_new_object(generic_object_t **row, ddl_column_t *column);
generic_object_t *new_object(ddl_column_t *column);

void dispose_object_list(generic_object_t **list);
void dispose_object(generic_object_t **object);
void add_object(generic_object_t **row, generic_object_t *object);

void set_object_value_ptr(generic_object_t *object, void *ptr);

int set_object_value_int(generic_object_t *object, int value);
int set_object_value_char(generic_object_t *object, char *value, int size);

int get_object_value_int(generic_object_t *object);
char *get_object_value_char(generic_object_t *object);

// test code
generic_object_t *new_test_row(int id, char name[100], ddl_column_t *list);

#endif // _GENERICOBJECT_H_
